package com.supertimetable.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.GridView;

/**
 * Created by Admin on 2018/1/11.
 */

public class StationarayGridiew extends GridView {
    GestureDetector gestureDetector;
    public StationarayGridiew(Context context) {
        super(context);
    }

    public StationarayGridiew(Context context, AttributeSet attrs) {
        super(context,attrs);
    }

    public void setGestureDetector(GestureDetector gestureDetector){
        this.gestureDetector=gestureDetector;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        super.onTouchEvent(ev);
        return gestureDetector.onTouchEvent(ev);
    }
    public void onMeasure(int widthMeasureSpace,int heightMeasurSpac){
        int expendSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpace,expendSpec);
    }
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        gestureDetector.onTouchEvent(ev);
        super.dispatchTouchEvent(ev);
        return true;
    }
}
